<template>
    手机号:
    <input type="text" v-model="Memphone">
    <input type="button" value="查询" @click="ShowMember">
   <table border="1">
    <thead>
        <tr>
        <td>卡号</td>
        <td>账号</td>
        <td>身份证号</td>
        <td>联系方式</td>
        <td>登录时间</td>
        <td>真实姓名</td>
        <td>类型</td>
        <td>等级</td>
    </tr>
</thead>
    <tbody v-for="init in Show">
        <td>{{ init.T_Id }}</td>
        <td>{{init.D_name}}</td>
        <td>{{init.Card  }}</td>
        <td>{{ init.Phone }}</td>
        <td>{{init.DateTime}}</td>
        <td>{{init.T_Tream}}</td>
        <td>{{init.TY_name}}</td>
        <td>{{ init.D_name }}</td>
        <td><input type="button" value="修改" @click="xiugai(init.T_Id)"></td>
        <td><input type="button" value="删除" @click="shanchu(init.T_Id)"></td>

    </tbody>
   </table>
</template>

<script setup lang="ts">

import {ref} from 'vue'
import { onMounted } from 'vue';
import axios from 'axios'
import { useRouter } from 'vue-router';
const userouter=useRouter();

const Memphone=ref("");


const Show=ref([{
    "T_Id":"",
    "Card": "",
    "DateTime": "",
    "T_Name": "",
    "Phone": "",
    "T_Tream": "",
    "IsMobile": true,
    "TY_name": "",
    "D_name": ""
}])
onMounted(()=>{
    ShowMember();
})

const ShowMember=()=>{
    axios.get("https://localhost:7281/api/Member/GetMembers",
    {
        params:{
            Phone:Memphone.value
        }
    })
    .then(res=>{
Show.value=res.data
    })
}
const xiugai=(T_Id:string)=>{
    userouter.push({
        name:"UpdaMember",
        params:{
            id:T_Id
        }
    }
    )
}
const shanchu=(T_Id:string)=>{
axios.delete("https://localhost:7281/api/Member/del",{
    params:{
        id:T_Id
    }
})
.then(res=>{
    if(res.data>0){
        alert('删除成功');
        ShowMember();
    }else{
        alert('删除失败')
    }
})
}
</script>

<style scoped>

</style>